package com.guanmi.ethereum.service;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;

import org.web3j.crypto.Credentials;
import org.web3j.protocol.core.methods.response.EthGasPrice;
import org.web3j.protocol.core.methods.response.EthSendTransaction;
import org.web3j.protocol.core.methods.response.EthTransaction;
import org.web3j.protocol.core.methods.response.TransactionReceipt;

import com.guanmi.ethereum.domain.ERC20TokenSolTemplate;
import com.guanmi.ethereum.domain.WalletResponseEntity;

public interface EthereumService {

	/**
	 * @Title: getAccountlist
	 * @Description: 获取账户列表
	 * @return List<String>
	 */
	WalletResponseEntity<List<String>> getAccountlist();

	/**
	 * @Title: generateNewWalletFile
	 * @Description: 创建账户
	 * @param password:密码
	 * @return String
	 */
	WalletResponseEntity<Credentials> generateNewWalletFile(String password);

	/**
	 * @Title: getBalance
	 * @Description: 获取用户余额
	 * @param address:账户
	 * @return BigInteger
	 */
	WalletResponseEntity<BigInteger> getBalance(String address);

	/**
	 * @Title: getTransactionCount
	 * @Description: 获取用户交易记录数
	 * @param address:账户
	 * @return BigInteger
	 */
	WalletResponseEntity<BigInteger> getTransactionCount(String address);

	/**
	 * @Title: getTransaction
	 * @Description: 获取交易信息
	 * @param transactionHash:交易的hash值
	 * @return EthTransaction
	 */
	WalletResponseEntity<EthTransaction> getTransaction(String transactionHash);

	/**
	 * @Description: 获取用户的账户 @param walletfile:密钥文件 @param password：密码 @return
	 * String @throws
	 */
	WalletResponseEntity<String> getAddress(String walletfile, String password);

	/**
	 * @Title: ethSendRawTransaction
	 * @Description: 转账
	 * @param walletfile:密钥文件
	 * @param password：密码
	 * @param toAddress:接受地址
	 * @param coinNum：数量
	 * @return EthSendTransaction
	 */
	WalletResponseEntity<EthSendTransaction> ethSendRawTransaction(String walletfile, String password, String toAddress,
			BigDecimal coinNum);

	/**
	 * @Description: 转账
	 * @param walletfile:密钥文件
	 * @param password：密码
	 * @param toAddress:收款账户
	 * @param coinNum：数量
	 * @return TransactionReceipt
	 */
	WalletResponseEntity<TransactionReceipt> transferSendFunds(String walletfile, String password, String toAddress,
			BigDecimal coinNum);

	WalletResponseEntity<EthGasPrice> ethGasPrice();

	/**
	 * @Description: 转账
	 * @param fromAddress:账号
	 * @param fromPassword：密码
	 * @param toAddress:收款账户
	 * @param coinNum：数量
	 * @return TransactionReceipt
	 */
	WalletResponseEntity<EthSendTransaction> personalSendTransaction(String fromAddress, String fromPassword,
			String toAddress, BigDecimal coinNum);
	
	/**
	 * 部署合约
	 * @param deployeraccount 合约账号
	 * @param initialSupply 总量
	 * @param tokenName 合约名称
	 * @param tokenSymbol 合约标识
	 * @return
	 */
	WalletResponseEntity<ERC20TokenSolTemplate> deployContract(String deployeraccount, BigDecimal initialSupply,
			String tokenName, String tokenSymbol);
	/**
	 * 部署合约
	 * @param walletfile 合约地址文件名
	 * @param password 密码
	 * @param initialSupply 总量
	 * @param tokenName 合约名称
	 * @param tokenSymbol 合约标识
	 * @return
	 */
	 WalletResponseEntity<ERC20TokenSolTemplate> deployContract(String walletfile, String password ,BigDecimal initialSupply,
				String tokenName, String tokenSymbol);
    /**
     * 合约转账
     * @param deployeraccount 合约账号
     * @param password 密码
     * @param contractAddress 合约地址
     * @param toAddress 转账地址
     * @param coinNum 转账数量
     * @return
     */
	WalletResponseEntity<TransactionReceipt> tokenERC20SendPassword(String deployeraccount,String password, String contractAddress,
			String toAddress, BigDecimal coinNum);
	
	/**
	 * 合约转账
	 * @param walletfile 合约地址文件名
	 * @param password 密码
	 * @param contractAddress 合约地址
	 * @param toAddress  转账地址
	 * @param coinNum 转账数量
	 * @return
	 */
	 WalletResponseEntity<TransactionReceipt> tokenERC20SendWalletFile(String walletfile,String password, String contractAddress, String toAddress,
	        BigDecimal coinNum);
	
	

	

}
